#include<cstdio>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
#include<stdlib.h>
int main()
{
    pid_t id=fork();
    char*const argv[]=
    {
        (char*)"ls",//类型转换，防止警告
        (char*)"-i",
        NULL
    };
    if(id==0)
    {
        //execl("/usr/bin/ls","ls","-i",NULL);
        //execv("/usr/bin/ls",argv);
        //execlp("ls","ls","-i",NULL);
        extern char** enviorn;
        execle("/usr/bin/ls","ls","-i",NULL,environ);
        printf("程序替换失败了\n");
        exit(2);
    }
    pid_t ret=waitpid(id,nullptr,0);
    if(ret>0)printf("等待子进程成功\n");
    return 0;
}


